﻿using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;
using JumbotPay.API.Alipay.Mobile;
using Aop.Api;
using Aop.Api.Domain;
using Aop.Api.Request;
using Aop.Api.Response;
namespace JumbotPay.WebFile.Alipay_Mobile
{
    public partial class _default : JumbotPay.UI.BasicPage
    {
        public string GenerateOutTradeNo()
        {
            var ran = new Random();
            return string.Format("{0}{1}", DateTime.Now.ToString("yyyyMMddHHmmss"), ran.Next(999));
        }
        public string Order_ID = "";
        public string Product_Name = "";
        public string Product_Desc = "";
        public string Order_Time = "";
        public string Order_Money = "";
        public string Pay_Url = "";
        public string Account_Alipay_Name;
        protected void Page_Load(object sender, EventArgs e)
        {
            ////////////////////////////////////////////请求参数////////////////////////////////////////////

            //必填参数//
            string appid = q("appid");//appid
            Order_ID = q("order_id");//订单号
            string sign = q("sign");
            string key = new JumbotPay.DAL.AppDAL().GetKey(appid);
            if (key == "")
            {
                Response.Write("无效的appid");
                Response.End();
            }
            string[] array0 ={
			    "order_id="+Order_ID,
                 "appid="+appid
				};
            if (!JumbotPay.Utils.Strings.CheckSign(array0, key, sign))
            {
                Response.Write("验签失败");
                Response.End();
            }
            object[] _value = new JumbotPay.DAL.OrderDAL().GetOrderFields("alipay", Order_ID, "", "product_name,product_desc,pay_amount,Order_Time,account_alipay,account_alipay_name");
            Product_Name = _value[0].ToString();                            //商品名称
            Product_Desc = _value[1].ToString();                                 //商品描述
            string total_amount = _value[2].ToString();
            Order_Time = Convert.ToDateTime(_value[3].ToString()).ToString("yyyy-MM-dd HH:mm:ss");
            Order_Money = Str2Double(_value[2].ToString()).ToString("f2");
            string account_alipay = _value[4].ToString();
            Account_Alipay_Name = _value[5].ToString();
            Pay_Url = "default_step2.aspx?account_no=" + account_alipay + "&order_id=" + Order_ID;

        }
    }
}
